﻿using System;
using System.ComponentModel;

namespace HalconDotNet
{
	/// <summary>Represents an instance of a Deep Neural Network training step result.</summary>
	// Token: 0x02000034 RID: 52
	public class HDlClassifierTrainResult : HHandle
	{
		// Token: 0x060004B6 RID: 1206 RVA: 0x0000883B File Offset: 0x00006A3B
		[EditorBrowsable(EditorBrowsableState.Never)]
		public HDlClassifierTrainResult() : base(HHandleBase.UNDEF)
		{
		}

		// Token: 0x060004B7 RID: 1207 RVA: 0x0001C0EC File Offset: 0x0001A2EC
		[EditorBrowsable(EditorBrowsableState.Never)]
		public HDlClassifierTrainResult(IntPtr handle) : base(handle)
		{
			this.AssertSemType();
		}

		// Token: 0x060004B8 RID: 1208 RVA: 0x0001C0FB File Offset: 0x0001A2FB
		[EditorBrowsable(EditorBrowsableState.Never)]
		public HDlClassifierTrainResult(HHandle handle) : base(handle)
		{
			this.AssertSemType();
		}

		// Token: 0x060004B9 RID: 1209 RVA: 0x0001C10A File Offset: 0x0001A30A
		private void AssertSemType()
		{
			base.AssertSemType("dl_classifier_train_result");
		}

		// Token: 0x060004BA RID: 1210 RVA: 0x0001C117 File Offset: 0x0001A317
		internal static int LoadNew(IntPtr proc, int parIndex, int err, out HDlClassifierTrainResult obj)
		{
			obj = new HDlClassifierTrainResult(HHandleBase.UNDEF);
			return obj.Load(proc, parIndex, err);
		}

		// Token: 0x060004BB RID: 1211 RVA: 0x0001C130 File Offset: 0x0001A330
		internal static int LoadNew(IntPtr proc, int parIndex, int err, out HDlClassifierTrainResult[] obj)
		{
			HTuple htuple;
			err = HTuple.LoadNew(proc, parIndex, err, out htuple);
			obj = new HDlClassifierTrainResult[htuple.Length];
			for (int i = 0; i < htuple.Length; i++)
			{
				obj[i] = new HDlClassifierTrainResult(HalconAPI.IsLegacyHandleMode() ? htuple[i].IP : htuple[i].H);
			}
			htuple.Dispose();
			return err;
		}

		/// <summary>
		///   Perform a training step of a deep-learning-based classifier on a batch of  images.
		///   Modified instance represents: Handle of the training results from the  deep-learning-based classifier.
		/// </summary>
		/// <param name="batchImages">Images comprising the batch.</param>
		/// <param name="DLClassifierHandle">Handle of the deep-learning-based classifier.</param>
		/// <param name="batchLabels">Corresponding labels for each of the images. Default: []</param>
		// Token: 0x060004BC RID: 1212 RVA: 0x0001C1A0 File Offset: 0x0001A3A0
		public HDlClassifierTrainResult(HImage batchImages, HDlClassifier DLClassifierHandle, HTuple batchLabels)
		{
			IntPtr proc = HalconAPI.PreCall(2131);
			HalconAPI.Store(proc, 1, batchImages);
			HalconAPI.Store(proc, 0, DLClassifierHandle);
			HalconAPI.Store(proc, 1, batchLabels);
			HalconAPI.InitOCT(proc, 0);
			int num = HalconAPI.CallProcedure(proc);
			HalconAPI.UnpinTuple(batchLabels);
			num = base.Load(proc, 0, num);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
			GC.KeepAlive(batchImages);
			GC.KeepAlive(DLClassifierHandle);
		}

		/// <summary>Clear the handle of a deep-learning-based classifier training result.</summary>
		/// <param name="DLClassifierTrainResultHandle">Handle of the training results from the  deep-learning-based classifier.</param>
		// Token: 0x060004BD RID: 1213 RVA: 0x0001C210 File Offset: 0x0001A410
		public static void ClearDlClassifierTrainResult(HDlClassifierTrainResult[] DLClassifierTrainResultHandle)
		{
			HTuple htuple = HHandleBase.ConcatArray(DLClassifierTrainResultHandle);
			IntPtr proc = HalconAPI.PreCall(2105);
			HalconAPI.Store(proc, 0, htuple);
			int procResult = HalconAPI.CallProcedure(proc);
			HalconAPI.UnpinTuple(htuple);
			HalconAPI.PostCall(proc, procResult);
			GC.KeepAlive(DLClassifierTrainResultHandle);
		}

		/// <summary>
		///   Clear the handle of a deep-learning-based classifier training result.
		///   Instance represents: Handle of the training results from the  deep-learning-based classifier.
		/// </summary>
		// Token: 0x060004BE RID: 1214 RVA: 0x0001C254 File Offset: 0x0001A454
		public void ClearDlClassifierTrainResult()
		{
			IntPtr proc = HalconAPI.PreCall(2105);
			base.Store(proc, 0);
			int procResult = HalconAPI.CallProcedure(proc);
			HalconAPI.PostCall(proc, procResult);
			GC.KeepAlive(this);
		}

		/// <summary>
		///   Return the results for the single training step of a deep-learning-based  classifier.
		///   Instance represents: Handle of the training results from the  deep-learning-based classifier.
		/// </summary>
		/// <param name="genParamName">Name of the generic parameter. Default: "loss"</param>
		/// <returns>Value of the generic parameter.</returns>
		// Token: 0x060004BF RID: 1215 RVA: 0x0001C288 File Offset: 0x0001A488
		public HTuple GetDlClassifierTrainResult(HTuple genParamName)
		{
			IntPtr proc = HalconAPI.PreCall(2116);
			base.Store(proc, 0);
			HalconAPI.Store(proc, 1, genParamName);
			HalconAPI.InitOCT(proc, 0);
			int num = HalconAPI.CallProcedure(proc);
			HalconAPI.UnpinTuple(genParamName);
			HTuple result;
			num = HTuple.LoadNew(proc, 0, num, out result);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
			return result;
		}

		/// <summary>
		///   Return the results for the single training step of a deep-learning-based  classifier.
		///   Instance represents: Handle of the training results from the  deep-learning-based classifier.
		/// </summary>
		/// <param name="genParamName">Name of the generic parameter. Default: "loss"</param>
		/// <returns>Value of the generic parameter.</returns>
		// Token: 0x060004C0 RID: 1216 RVA: 0x0001C2E0 File Offset: 0x0001A4E0
		public HTuple GetDlClassifierTrainResult(string genParamName)
		{
			IntPtr proc = HalconAPI.PreCall(2116);
			base.Store(proc, 0);
			HalconAPI.StoreS(proc, 1, genParamName);
			HalconAPI.InitOCT(proc, 0);
			int num = HalconAPI.CallProcedure(proc);
			HTuple result;
			num = HTuple.LoadNew(proc, 0, num, out result);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
			return result;
		}

		/// <summary>
		///   Perform a training step of a deep-learning-based classifier on a batch of  images.
		///   Modified instance represents: Handle of the training results from the  deep-learning-based classifier.
		/// </summary>
		/// <param name="batchImages">Images comprising the batch.</param>
		/// <param name="DLClassifierHandle">Handle of the deep-learning-based classifier.</param>
		/// <param name="batchLabels">Corresponding labels for each of the images. Default: []</param>
		// Token: 0x060004C1 RID: 1217 RVA: 0x0001C330 File Offset: 0x0001A530
		public void TrainDlClassifierBatch(HImage batchImages, HDlClassifier DLClassifierHandle, HTuple batchLabels)
		{
			this.Dispose();
			IntPtr proc = HalconAPI.PreCall(2131);
			HalconAPI.Store(proc, 1, batchImages);
			HalconAPI.Store(proc, 0, DLClassifierHandle);
			HalconAPI.Store(proc, 1, batchLabels);
			HalconAPI.InitOCT(proc, 0);
			int num = HalconAPI.CallProcedure(proc);
			HalconAPI.UnpinTuple(batchLabels);
			num = base.Load(proc, 0, num);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
			GC.KeepAlive(batchImages);
			GC.KeepAlive(DLClassifierHandle);
		}
	}
}
